package com.wzu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wzu.entity.ApplyInfo;
import com.wzu.mapper.ApplyInfoMapper;
import com.wzu.service.ApplyInfoService;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class ApplyInfoServiceImpl extends ServiceImpl<ApplyInfoMapper, ApplyInfo> implements ApplyInfoService {
    @Override
    public List<ApplyInfo> searchApplyInfo(String cardId, String insuredName, String ruralCardNo, String auditStatus, String remitStatus) {
        QueryWrapper<ApplyInfo> wrapper = new QueryWrapper<>();
        if (cardId != null && !cardId.isEmpty()) {
            wrapper.like("card_id", cardId);
        }
        if (insuredName != null && !insuredName.isEmpty()) {
            wrapper.like("insured_name", insuredName);
        }
        if (ruralCardNo != null && !ruralCardNo.isEmpty()) {
            wrapper.like("rural_card_no", ruralCardNo);
        }
        if (auditStatus != null && !auditStatus.isEmpty()) {
            wrapper.eq("audit_status", auditStatus);
        }
        if (remitStatus != null && !remitStatus.isEmpty()) {
            wrapper.eq("remit_status", remitStatus);
        }
        return list(wrapper);
    }
    @Override
    public boolean addApplyInfo(ApplyInfo applyInfo) {
        return save(applyInfo);
    }
    @Override
    public boolean updateApplyInfo(ApplyInfo applyInfo) {
        return updateById(applyInfo);
    }
    @Override
    public boolean deleteApplyInfo(Long id) {
        return removeById(id);
    }
} 